package com.ming.seatMonitoring.service.ServiceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ming.seatMonitoring.mapper.RoomInfoMapper;
import com.ming.seatMonitoring.pojo.DO.RoomInfoDO;
import com.ming.seatMonitoring.service.RoomInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author 小明
 * @date 2021/10/21
 * @description
 */
@Service
public class RoomInfoServiceImpl extends ServiceImpl<RoomInfoMapper,RoomInfoDO> implements RoomInfoService {
    @Autowired
    private RoomInfoMapper roomInfoMapper;

    @Override
    public boolean addRoomInfo(RoomInfoDO roomInfoDO) {
        roomInfoDO.setCreateTime(new Date());
        return roomInfoMapper.addRoomInfo(roomInfoDO);
    }

    @Override
    public boolean deleteRoomInfo(int roomId) {
        return roomInfoMapper.deleteRoomInfo(roomId, new Date());
    }

    @Override
    public Page<RoomInfoDO> getRoomInfo(Page<RoomInfoDO> page) {

        return roomInfoMapper.selectRoomInfoByPage(page);
    }

    @Override
    public RoomInfoDO searchRoom(int roomId) {
        return roomInfoMapper.searchRoom(roomId);
    }

    @Override
    public boolean updateRoomInfo(RoomInfoDO roomInfoDO) {
        roomInfoDO.setUpdateTime(new Date());
        QueryWrapper<RoomInfoDO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("roomId", roomInfoDO.getRoomId());
        return update(roomInfoDO,queryWrapper);
    }


}
